Foliage Model Generator

Description

A system for the generation of 3D foliage models that are able to be exported as OBJ files. Developed in C++ using the DirectX11 framework as part of the Advanced Technology final-year module of BSc Games Technology.

The system is capable of producing models of 3 different foliage types: flowers, vines and bamboo. The characteristics of the generated foliage models are able to be altered by adjusting parameters using a GUI.

In order to generate foliage models, plant components are first created from scratch through the combination of vertices. These plant components are then combined algorithmically to create the resulting plant.

The plant component's are transformed by adjusting their local matrices which allows for the rotation, scale and positioning of the components to be adjusted.

Through the manipulation of these parameters the system is capable of producing a range of unique foliage models.

The resulting foliage models can be exported to the .OBJ file type which allows them to be imported into game engines such as Unity or Unreal.

Foliage Types

Mobirise Website Builder
Flower

Generated flowers are made up of three different elements, stems, leaves, and petals. The petals are positions at the highest point of the stem segments, ensuring that the flower head is always positioned at the
top of the flower model.
The petals are laid out in a
circular shape, with an equal distance between each
petal object. The rotation of each of the petals on the
y axis is calculated by dividing 360 by the number of
petals, then multiplying that value by the current petal count.

Mobirise Website Builder
Vines

Vine models are made up of a number of connected stem
segments, each of which have different rotation values. Incrementing a curve multiplier value gives a curved shape to the vine, giving it a more realistic look. The curve multiplier continues to increment based on the current stem index until it reaches a maximum value, at which point it decrements causing the vine to curve back in the opposite direction.
Leaves are positioned along the length of the vine’s stem at the top of each the stem segment. The z rotation of the leaves is set to be equal to the z rotation of the stem that it is attached to then every second leaf’s z rotation is subtracted by 180 which results in the leaves being positioned on alternating sides of the stem.

Mobirise Website Builder
Bamboo

The bamboo generation works by simply connecting
stem segments together vertically similarly to the vine
generation, however unlike the vine generation no rotation is applied to the bamboo’s stem segments. Leaves
are positioned along the stem of the bamboo starting
at the highest point of it’s corresponding stem segment.

Model Exporting

This system has a feature to export the generated plant models as .OBJ files. In order to correctly get the position of each of the plant elements the system must their vertex positions in world space. By transforming a
vector containing the vertex local position by the world matrix, we result in a vector containing the vertex position in world space which allows for the vertex positions to be exported accurately.
Models are exported as .OBJ by looping through each component of the plant and writing each of the vertices' positions in world space, then continues to write the texture coordinate and normal positions for each surface.

Designed with ‌

Landing Page Creator